<!--
 * @Author: wjk
 * @Date: 2019-12-31 15:40:51
 * @LastEditors: wjk
 * @LastEditTime: 2019-12-31 15:51:20
 * @description: file content
 -->
<template>
  <base-page-view class-name="page-container userInfo">
    <view class="sLine_box">
      <view class="sLine" @click="userlogout">
        <view class="lCont">注销账号</view>
        <view class="rCont">
          <image src="/static/images/mine/list_more.png" alt="" class="icon_my_more" />
        </view>
      </view>
    </view>
    <confirm-popup ref="confirm" />
  </base-page-view>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'
import confirmPopup from '@/components/confirmPopup/index'
import './index.scss'
export default {
  components: {
    confirmPopup
  },
  computed: {
    ...mapGetters(['user'])
  },
  methods: {
    userlogout() {
      this.$sensorTrack('CLICKBUTTON', {
        page_name: 'setting',
        button_name: '注销账号',
        mobile: this.user.mobile
      })
      this.$refs.confirm.show({
        title: '提示',
        content: '注销用户信息后，将无法再使用该号码登录碧选，请慎重考虑是否注销',
        cancleTxtStyle: 'background-color: #fff;color: #ff759f;border-bottom-left-radius: 20rpx;border-right: 1px solid #eee',
        yesTxtStyle: 'background-color: #fff;color: #ccc;border-bottom-right-radius: 20rpx',
        contentStyle: 'color: #333',
        yesCb: async() => {
          this.$sensorTrack('CLICKBUTTON', {
            page_name: 'setting',
            button_name: '确认注销',
            mobile: this.user.mobile
          })
          const res = await this.$api.mineApi.myInfoLogout()
          if (res.success) {
            this.LOGOUT_USER()
            uni.showToast({
              title: '注销成功',
              icon: 'none',
              duration: 2000,
              mask: true,
              success: () => {
                setTimeout(() => {
                  uni.reLaunch({ url: '/pages/home/index' })
                }, 1000)
              }
            })
          }
        }
      })
    },
    ...mapActions(['LOGOUT_USER'])
  }
}
</script>
